package net.caixiaomi.info.adapter;

import android.support.annotation.Nullable;

import net.caixiaomi.info.R;
import net.caixiaomi.info.base.quickadapter.BaseMultiItemQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseViewHolder;
import net.caixiaomi.info.base.quickadapter.entity.MultiItemEntity;
import net.caixiaomi.info.model.OpenPrizeMatchEntity;
import net.caixiaomi.info.model.OpenPrizeMatchListEntity;
import net.caixiaomi.info.util.Constants;

import java.util.List;

/**
 * Created by mac on 2018/9/8.
 */

public class OpenPrizeFootBallAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

    public OpenPrizeFootBallAdapter(@Nullable List<MultiItemEntity> data) {
        super(data);
        addItemType(Constants.ITEM_MATCH_LIVE0, R.layout.open_prize_football_item_layout);
        addItemType(Constants.ITEM_MATCH_LIVE1, R.layout.open_prize_footbal_item_header_layout);
    }

    @Override
    protected void convert(BaseViewHolder helper, MultiItemEntity item) {
        try {
            switch (helper.getItemViewType()) {
                case Constants.ITEM_MATCH_LIVE1:
                    bindHead(helper, item);
                    break;
                case Constants.ITEM_MATCH_LIVE0:
                    bindItem(helper, item);
                    break;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void bindHead(BaseViewHolder helper, MultiItemEntity item){
        OpenPrizeMatchListEntity entity= (OpenPrizeMatchListEntity) item;
        helper.setText(R.id.prize_date,entity.getDateStr());
        helper.setText(R.id.prize_des,entity.getPrizeMatchStr());
    }

    private void bindItem(BaseViewHolder helper, MultiItemEntity item){
        OpenPrizeMatchEntity entity= (OpenPrizeMatchEntity) item;
        helper.setText(R.id.prize_football_time,entity.getChangciId()+"  "+entity.getMatchTime());
        helper.setText(R.id.prize_football_name,entity.getCupName());
        helper.setText(R.id.prize_football_host,entity.getHomeTeamAbbr());
        helper.setText(R.id.prize_football_visitor,entity.getVisitTeamAbbr());
        helper.setText(R.id.prize_football_crs,entity.getWhole());
        helper.setText(R.id.prize_football_half,"半场"+entity.getHalf());
        helper.setText(R.id.prize_football_result0,entity.getHad());
        helper.setText(R.id.prize_football_result1,entity.getHhad());
        helper.setText(R.id.prize_football_result2,entity.getCrs());
        helper.setText(R.id.prize_football_result3,entity.getTtg());
        helper.setText(R.id.prize_football_result4,entity.getHafu());
    }
}
